{include file="layout/head.tpl"}
{include file="layout/menu.tpl"}

{literal}

<script type="text/javascript" src="include/js/jquery.validate.min.js"></script>

<script type="text/javascript">

$().ready(function() {
    
    $("#frmCadResposta").validate({
        rules: {
            descricao: {
                required: true
            }
        }
    });

    $("#btsalvarResposta").click(function(){

        var enqueteID = $("#enqueteID").val();
        var respostaID = $("#respostaID").val();
        var descricao = $("#descricao").val().trim();

        $("#tbResposta").append('<img src="include/images/ajax-loader.gif"/>');
        $("#tbResposta").load("RespostaAction.salvar",
            {
                descricao : descricao,
                enqueteID : enqueteID,
                respostaID: respostaID
            }
        ,function(){
            $("#respostaID").val(0);
            $("#descricao").val('');
        });
    })
      
});

function excluirResposta(respostaID){

    var enqueteID = $("#enqueteID").val();

    $("#tbResposta").append('<img src="include/images/ajax-loader.gif"/>');
    $("#tbResposta").load("RespostaAction.excluirAjax",
        {
            enqueteID : enqueteID,
            respostaID: respostaID

        }
    );
}

</script>
{/literal}

<div id="content" class="block-border">

    <div class="block-content">
        <div class="h1 with-menu"><h1>Cadastro de Resposta</h1></div>

{msg obj=$msg|default:null type="small"}
{display_errors errors=$errosValidacao|default:null}

        <div class="columns">

            <div class="colx1-left">
                <!-- Add the class 'form' -->
                <form id="frmCadResposta" action="" class="form" method="post">

                    <input type="hidden" name="respostaID" id="respostaID" value="{$respostaID|default:0}" />
                    <input type="hidden" name="enqueteID" id="enqueteID" value="{$enqueteID|default:0}" />

                    <fieldset>
                        <legend>Dados da Enquete</legend>
                            <p>
                                <label class="required" for="descricao">Descrição:</label>
                                <input type="text" class="full-width" title="" value="{$descricao|default:''}" name="descricao" id="descricao" style="width: 80%">
                                <a title="Salvar Resposta" href="javascript:void(0);" id="btsalvarResposta" class="with-tip">
                                    <img alt="add" src="include/images/icons/fugue/plus-circle.png" width="16" height="16"/>
                                </a>
                            </p>
                    </fieldset>

                    <fieldset>
                        <legend>Respostas Cadastradas</legend>

                        {if !isset($respostas)} {$respostas = array()}    {/if}
                        <div id="tbResposta">{include file="view/resposta/tabelaSimples.tpl"}</div>

                    </fieldset>

                    <div class="btAction">
			 {action_button label="Limpar" type="reset" class="grey"}
                         {action_button label="Salvar" type="submit"}
                    </div>

                </form>
            </div>
        </div>
    </div>





</div>

{include file="layout/footer.tpl"}